package 程序员面试金典;

public class 排序矩阵查找 {

    //从右上角开始找，或者从左下角开始找
    public boolean searchMatrix(int[][] matrix, int target) {
        if (matrix.length==0)
            return false;
        for (int i=0,j=matrix[0].length-1; i<matrix.length && j>=0;){
            if (matrix[i][j]>target)
                j--;
            else if (matrix[i][j]<target)
                i++;
            else
                return true;
        }
        return false;
    }
}
